package com.roncoo.pay.account.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.plugins.Page;
import com.roncoo.pay.account.entity.RpAccount;
import com.roncoo.pay.account.mapper.RpAccountMapper;
import com.roncoo.pay.account.service.RpAccountService;
import com.roncoo.pay.common.core.page.PageBean;
import com.roncoo.pay.common.core.page.PageParam;

/**
 * 账户service实现类
 */
@Service("rpAccountService")
public class RpAccountServiceImpl implements RpAccountService{

	@Autowired
	private RpAccountMapper rpAccountMapper;
	
	@Override
	public void saveData(RpAccount rpAccount) {
		rpAccountMapper.insert(rpAccount);
	}

	@Override
	public void updateData(RpAccount rpAccount) {
		rpAccountMapper.updateById(rpAccount);
	}

	@Override
	public RpAccount getDataById(String id) {
		return rpAccountMapper.selectById(id);
	}

	@Override
	public PageBean<RpAccount> listPage(PageParam pageParam, RpAccount rpAccount) {
		Page<RpAccount> page = new Page<RpAccount>(pageParam.getPageNum(), pageParam.getNumPerPage());
		List<RpAccount> list = rpAccountMapper.listPage(page , rpAccount);
		PageBean<RpAccount> pb = new PageBean<RpAccount>(pageParam.getPageNum(), pageParam.getNumPerPage(), page.getTotal(),list);
		return pb;
	}
	
	@Override
	public RpAccount getDataByUserNo(String userNo){
		RpAccount account = new RpAccount();
		account.setUserNo(userNo);
		return rpAccountMapper.selectOne(account);
	}
}